/*
 * @lc app=leetcode.cn id=80 lang=javascript
 *
 * [80] 删除有序数组中的重复项 II
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  let length = nums.length,
    i = 2
  for (let j = 2; j < length; j++) {
    if (nums[i - 2] != nums[j]) {
      nums[i] = nums[j]
      i++
    }
  }
  return i
}
// @lc code=end
